﻿using System;
using System.Collections;
using System.Collections.Generic;
using Me.Prettyprint.Cassandra.Connection;
using Me.Prettyprint.Cassandra.Serializers;
using Me.Prettyprint.Cassandra.Service;
using Me.Prettyprint.Cassandra.Utils;
using Me.Prettyprint.Hector.Api;
using Me.Prettyprint.Hector.Api.Beans;
using Me.Prettyprint.Hector.Api.Query;
using Org.Apache.Cassandra.Thrift;

namespace Me.Prettyprint.Cassandra.Model
{
    /// <summary>
    /// Default implementation of CounterSuperRow interface. The class converts thrift
    /// CounterSuperColumn to Hector CounterSuperRow.
    /// </summary>
    /// <typeparam name="K"></typeparam>
    /// <typeparam name="SN"></typeparam>
    /// <typeparam name="N"></typeparam>
    public class CounterSuperRowImpl<K, SN, N> : CounterSuperRow<K, SN, N>
    {
        public CounterSuperRowImpl(K bs, List<CounterSuperColumn> thriftSuperColumns,
                                 Serializer<SN> sNameSerializer, Serializer<N> nameSerializer)
        {
            if (bs == null || thriftSuperColumns == null || nameSerializer == null)
            {
                throw new NullReferenceException("Key, SuperColumn and Name serializer cannot be null");
            }
            Key = bs;
            Slice = new CounterSuperSliceImpl<SN, N>(thriftSuperColumns, sNameSerializer, nameSerializer);
        }
        public K Key
        {
            get; protected set;
        }
        public CounterSuperSlice<SN, N> Slice
        {
            get;
            protected set;
        }
        public CounterSuperSlice<SN, N> SuperSlice
        {
            get
            {
                return Slice;
            }
        }
        public override string ToString()
        {
            return "SuperRow(" + Key + "," + Slice + ")";
        }

    }
}
